package com.ruoyi.huanghefd.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.huanghefd.service.BasedataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author gnplum
 * @Date 2023/11/1 16:22
 * @PackageName:com.ruoyi.huanghefd.controller
 * @ClassName: BasedataController
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("/huanghefd")
public class BasedataController {
    private static final Logger log = LoggerFactory.getLogger(BasedataController.class);

    @Resource
    private BasedataService basedataService;

    /**
     * @return java.lang.String
     * http://localhost:18080/huanghefd/getDep?depId=11
     * @Author gnplum
     * @Description //获取部门信息
     * @Date 16:26 2023/11/1
     **/
    @GetMapping("/getDep")
    public AjaxResult getDep(@RequestParam(required = false, value = "depId") String depId) {
        log.info(">> 获取部门信息开始");
        AjaxResult ajax = basedataService.queryDeps(depId);
        log.info("<< 获取部门信息结束==" + ajax);
        return ajax;
    }

    /**
     * @return java.lang.String
     * http://localhost:18080/huanghefd/getSysuserfd?userId=130016&depId=1607
     * @Author gnplum
     * @Description //获取用户信息
     * @Date 16:26 2023/11/1
     **/
    @GetMapping("/getSysuserfd")
    public AjaxResult getSysuserfd(@RequestParam(required = false, value = "userId") String userId, @RequestParam(required = false, value = "userName") String userName, @RequestParam(required = false, value = "depId") String depId) {

        log.info(">> 获取用户信息开始");
        AjaxResult ajax = basedataService.querySysuserfds(userId, userName, depId);
        log.info("<< 获取用户信息结束==" + ajax);
        return ajax;
    }

    /**
     * @param userId
     * @param password
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @Author gnplum
     * @Description //校验签名
     * @Date 21:41 2023/11/20
     **/
    @GetMapping("/verifySign")
    public AjaxResult verifySign(@RequestParam(required = false, value = "userId") String userId, @RequestParam(required = false, value = "password") String password) {
        log.info("校验用户密码==" + userId + password);
        return basedataService.verifySignByPsw(userId, password);
    }

}
